package com.da.javatest.leetCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenlida
 * @date 2019/3/13 11:02
 * @description
 */
public class Code179 {
    public static void main(String[] args) {
        System.out.println(new Code179().largestNumber(new int[] {824, 938, 1399, 5607, 6973, 5703, 9609, 4398, 8247}));
        System.out.println(new Code179().largestNumber(new int[] {121, 12}));
        System.out.println(new Code179().largestNumber(new int[] {128, 12}));
    }

    public String largestNumber(int[] nums) {
        StringBuilder sb = new StringBuilder();
        List<String> list = new ArrayList<>();
        for (int num : nums) {
            list.add(num + "");
        }
        list.stream().sorted((y, x) -> (x + y).compareTo(y + x)).forEach(sb::append);
        String s = sb.toString();
        return s.startsWith("0") ? "0" : s;
    }
}
